/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pl.cezary.butler.walili.client.network;

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.jms.JMSException;
import javax.jms.Message;
import org.springframework.beans.factory.annotation.Autowired;

/**
 *
 * @author Czarek
 */
public class NetworkStatsMessageListener implements javax.jms.MessageListener{
    
    private static final Logger log = Logger.getLogger(NetworkStatsMessageListener.class.getName());
    
    @Autowired
    private final INetworkStats stats;

    @Autowired
    public NetworkStatsMessageListener(INetworkStats stats) {
        this.stats = stats;
    }

    @Override
    public void onMessage(Message msg) {        
        try {
            stats.read(msg.getIntProperty("read"));
        } catch (JMSException ex) {
            Logger.getLogger(NetworkStatsMessageListener.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    
    
    
    
}
